package com.demo.petshop.controller;

import com.demo.petshop.entity.OrderItems;
import com.demo.petshop.service.OrderItemsService;
import com.demo.petshop.util.Result;
import com.mybatisflex.core.paginate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 *  控制层。
 *
 * @author lenovo
 * @since 2025-06-11
 */
@RestController
@RequestMapping("/orderItems")
public class OrderItemsController {

    @Autowired
    private OrderItemsService orderItemsService;


    @PostMapping("save")
    public boolean save(@RequestBody OrderItems orderItems) {
        return orderItemsService.save(orderItems);
    }


    @DeleteMapping("remove/{id}")
    public boolean remove(@PathVariable Serializable id) {
        return orderItemsService.removeById(id);
    }


    @PostMapping("update")
    public Object update(@RequestBody OrderItems orderItems) {
        return Result.success(orderItemsService.updateById(orderItems));
    }


    @GetMapping("list")
    public List<OrderItems> list() {
        return orderItemsService.list();
    }


    @GetMapping("getInfo/{id}")
    public OrderItems getInfo(@PathVariable Serializable id) {
        return orderItemsService.getById(id);
    }


    @GetMapping("page")
    public Page<OrderItems> page(Page<OrderItems> page) {
        return orderItemsService.page(page);
    }


}
